# -*- coding: utf-8 -*-

from odoo import models, fields


class CpqPricingStrategy(models.Model):
    _name = 'cpq.pricing.strategy'
    _description = '定价策略'
    
    # ============ 基础信息 ============
    name = fields.Char(
        string='策略名称',
        required=True
    )
    
    active = fields.Boolean(
        string='有效',
        default=True
    )
    
    company_id = fields.Many2one(
        'res.company',
        string='公司',
        default=lambda self: self.env.company
    )
    
    # ============ 策略类型 ============
    strategy_type = fields.Selection([
        ('cost_plus', '成本加成'),
        ('target_margin', '目标利润率'),
        ('market_based', '市场定价'),
        ('competitive', '竞争性定价')
    ], string='策略类型', required=True, default='cost_plus')
    
    # ============ 成本加成法 ============
    markup_rate = fields.Float(
        string='加成率(%)',
        default=15.0,
        help='在成本基础上加价的百分比'
    )
    
    # ============ 目标利润率法 ============
    target_margin_rate = fields.Float(
        string='目标利润率(%)',
        default=20.0,
        help='目标利润占售价的百分比'
    )
    
    # ============ 价格区间 ============
    min_price = fields.Monetary(
        string='最低价格',
        currency_field='currency_id'
    )
    
    max_price = fields.Monetary(
        string='最高价格',
        currency_field='currency_id'
    )
    
    currency_id = fields.Many2one(
        'res.currency',
        related='company_id.currency_id',
        string='货币'
    )
    
    # ============ 适用范围 ============
    product_category_ids = fields.Many2many(
        'product.category',
        string='适用产品分类'
    )
    
    partner_ids = fields.Many2many(
        'res.partner',
        string='适用客户'
    )
    
    # ============ 备注 ============
    description = fields.Text(
        string='描述'
    )
    
    notes = fields.Text(
        string='备注'
    )

